<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="text" indent="no"/>
	<xsl:template match="/">
		<xsl:text>param.UIDROOT=1.3.6.1.4.1.3834.0.0.&#10;</xsl:text>
		<xsl:for-each select="/scan/dicom/dicomElement[@type='ABSENT']">set.[<xsl:value-of select="@groupId"/>,<xsl:value-of select="@elementId"/>]<xsl:value-of select="translate(@name, ' ', '')"/>=@remove()<xsl:text>&#10;</xsl:text>
		</xsl:for-each>
		<xsl:for-each select="/scan/dicom/dicomElement[@type='EMPTY']">set.[<xsl:value-of select="@groupId"/>,<xsl:value-of select="@elementId"/>]<xsl:value-of select="translate(@name, ' ', '')"/>=@empty()<xsl:text>&#10;</xsl:text>
		</xsl:for-each>
		<xsl:for-each select="/scan/dicom/dicomElement[@type='NO_CONTENT']">set.[<xsl:value-of select="@groupId"/>,<xsl:value-of select="@elementId"/>]<xsl:value-of select="translate(@name, ' ', '')"/>=@if(this, isblank) {@keep()} {@empty()}<xsl:text>&#10;</xsl:text>
		</xsl:for-each>
		<xsl:for-each select="/scan/dicom/dicomElement[@type='PRESENT']">
			<xsl:choose>
				<xsl:when test="format/@name='CROGeneratedUID' and @groupId!='0002' and @elementId!='0003'">set.[<xsl:value-of select="@groupId"/>,<xsl:value-of select="@elementId"/>]<xsl:value-of select="translate(@name, ' ', '')"/>=@if(this, isblank) {@require()} {@hashuid(@UIDROOT,this)}<xsl:text>&#10;</xsl:text>
				</xsl:when>
				<xsl:otherwise>set.[<xsl:value-of select="@groupId"/>,<xsl:value-of select="@elementId"/>]<xsl:value-of select="translate(@name, ' ', '')"/>=@require()<xsl:text>&#10;</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
		<xsl:for-each select="/scan/dicom/dicomElement[@type='OPTIONAL']">
			<xsl:choose>
				<xsl:when test="format/@name='CROGeneratedUID' and @groupId!='0002' and @elementId!='0003'">set.[<xsl:value-of select="@groupId"/>,<xsl:value-of select="@elementId"/>]<xsl:value-of select="translate(@name, ' ', '')"/>=@if(this, isblank) {@keep()} {@hashuid(@UIDROOT,this)}<xsl:text>&#10;</xsl:text>
				</xsl:when>
				<xsl:otherwise>set.[<xsl:value-of select="@groupId"/>,<xsl:value-of select="@elementId"/>]<xsl:value-of select="translate(@name, ' ', '')"/>=@keep()<xsl:text>&#10;</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
		<xsl:for-each select="/scan/dicom/dicomElement[@type='CONTENT']">
			<xsl:choose>
				<xsl:when test="format/@name='CROGeneratedUID' and @groupId!='0002' and @elementId!='0003'">set.[<xsl:value-of select="@groupId"/>,<xsl:value-of select="@elementId"/>]<xsl:value-of select="translate(@name, ' ', '')"/>=@if(this, isblank) {@keep()} {@hashuid(@UIDROOT,this)}<xsl:text>&#10;</xsl:text>
				</xsl:when>
				<xsl:otherwise>#set.[<xsl:value-of select="@groupId"/>,<xsl:value-of select="@elementId"/>]<xsl:value-of select="translate(@name, ' ', '')"/>=@keep()<xsl:text>&#10;</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
		<xsl:text>set.[0012,0062]PatientIdentityRemoved=YES&#10;</xsl:text>
		<xsl:text>set.[0012,0063]DeidentificationMethod=NITS&#10;</xsl:text>
		<xsl:text>remove.privategroups=&#10;</xsl:text>
	</xsl:template>
</xsl:stylesheet>
